package com.hippo.liteflow.component.nodeComponent;

import com.yomahub.liteflow.annotation.LiteflowComponent;
import com.yomahub.liteflow.core.NodeComponent;
import lombok.extern.slf4j.Slf4j;

import static java.lang.Thread.sleep;

/**
 * @ClassName CCmp
 * @Description TODO 组件D
 * @Author tangxl
 * @create 2023-03-30 16:38
 **/
@Slf4j
@LiteflowComponent("d")
public class DCmp extends NodeComponent {
    @Override
    public void process() throws Exception {
        log.info("我是D,我执行业务了");
        sleep(3000);
    }

    /**
     * 业务逻辑处理成功后的回调
     * @throws Exception
     */
    @Override
    public void onSuccess() throws Exception {
        log.warn("-------D执行成功----------");
    }

    /**
     * 业务逻辑处理失败后的回调
     * @throws Exception
     */
    @Override
    public void onError() throws Exception {
        log.warn("--------D执行失败---------");
        // onError方法本身抛错，那么最终抛到最外面的错，是主方法里的错
        throw new Exception("D执行失败");
    }
}
